<?xml version="1.0" encoding="iso-8859-1" standalone="no"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="Content-Type" content=
    "application/xhtml+xml; charset=iso-8859-1" />
    <title>
      GCC-9.2.0
    </title>
    <link rel="stylesheet" type="text/css" href="../stylesheets/lfs.css" />
    <meta name="generator" content="DocBook XSL Stylesheets V1.79.1" />
    <link rel="stylesheet" href="../stylesheets/lfs-print.css" type=
    "text/css" media="print" />
  </head>
  <body class="blfs" id="blfs-9.1">
    <div class="navheader">
      <h4>
        Beyond Linux<sup>�</sup> From Scratch <span class="phrase">(System
        V</span> Edition) - Version 9.1
      </h4>
      <h3>
        Chapter&nbsp;13.&nbsp;Programming
      </h3>
      <ul>
        <li class="prev">
          <a accesskey="p" href="expect.html" title="Expect-5.45.4">Prev</a>
          <p>
            Expect-5.45.4
          </p>
        </li>
        <li class="next">
          <a accesskey="n" href="gc.html" title="GC-8.0.4">Next</a>
          <p>
            GC-8.0.4
          </p>
        </li>
        <li class="up">
          <a accesskey="u" href="prog.html" title=
          "Chapter&nbsp;13.&nbsp;Programming">Up</a>
        </li>
        <li class="home">
          <a accesskey="h" href="../index.html" title=
          "Beyond Linux� From Scratch     (System V Edition) - Version 9.1">Home</a>
        </li>
      </ul>
    </div>
    <div class="sect1" lang="en" xml:lang="en">
      <h1 class="sect1">
        <a id="gcc" name="gcc"></a>GCC-9.2.0
      </h1>
      <div class="package" lang="en" xml:lang="en">
        <h2 class="sect2">
          Introduction to GCC
        </h2>
        <p>
          The <span class="application">GCC</span> package contains the GNU
          Compiler Collection. This page describes the installation of
          compilers for the following languages: C, C++, D, Fortran,
          Objective C, Objective C++, and Go.
        </p>
        <p>
          This package is known to build and work properly using an LFS-9.1
          platform.
        </p>
        <div class="admon caution">
          <img alt="[Caution]" src="../images/caution.png" />
          <h3>
            Caution
          </h3>
          <p>
            If you are upgrading <span class="application">GCC</span> from
            any other version prior to 9.2.0, then you must be careful
            compiling 3rd party kernel modules. You should ensure that the
            kernel and all its native modules are also compiled using the
            same version of <span class="application">GCC</span> that you use
            to build the 3rd party module. This issue does not affect native
            kernel (and kernel modules) updates, as the instructions below
            are a complete reinstallation of <span class=
            "application">GCC</span>. If you have existing 3rd party modules
            installed, ensure they are recompiled using the updated version
            of <span class="application">GCC</span>. As always, never update
            the kernel headers from the ones used when <span class=
            "application">Glibc</span> was compiled during LFS.
          </p>
          <p>
            Some system headers need to be fixed to be used with GCC. This is
            done during the installation of GCC, and the <span class=
            "quote">&ldquo;<span class="quote">fixed</span>&rdquo;</span>
            headers are installed in <code class=
            "filename">/usr/lib/gcc/&lt;machine triplet&gt;/&lt;GCC
            version&gt;/include-fixed</code> . This is harmless if GCC is
            built during the LFS stage. But if you reinstall GCC in BLFS,
            some of the BLFS packages may be <span class=
            "quote">&ldquo;<span class="quote">fixed</span>&rdquo;</span>. If
            one of those packages is reinstalled afterwards, the <span class=
            "quote">&ldquo;<span class="quote">fixed</span>&rdquo;</span>
            headers are not updated, which may lead to version mismatches. In
            case that happens, the <span class="quote">&ldquo;<span class=
            "quote">fixed</span>&rdquo;</span> headers must be updated by
            running (as <code class="systemitem">root</code>): <span class=
            "command"><strong>/usr/libexec/gcc/x86_64-pc-linux-gnu/9.2.0/install-tools/mkheaders</strong></span>
            . The machine triplet may be different on a 32bit system.
          </p>
        </div>
        <h3>
          Package Information
        </h3>
        <div class="itemizedlist">
          <ul class="compact">
            <li class="listitem">
              <p>
                Download (HTTP): <a class="ulink" href=
                "https://ftp.gnu.org/gnu/gcc/gcc-9.2.0/gcc-9.2.0.tar.xz">https://ftp.gnu.org/gnu/gcc/gcc-9.2.0/gcc-9.2.0.tar.xz</a>
              </p>
            </li>
            <li class="listitem">
              <p>
                Download (FTP): <a class="ulink" href=
                "ftp://ftp.gnu.org/gnu/gcc/gcc-9.2.0/gcc-9.2.0.tar.xz">ftp://ftp.gnu.org/gnu/gcc/gcc-9.2.0/gcc-9.2.0.tar.xz</a>
              </p>
            </li>
            <li class="listitem">
              <p>
                Download MD5 sum: 3818ad8600447f05349098232c2ddc78
              </p>
            </li>
            <li class="listitem">
              <p>
                Download size: 67 MB
              </p>
            </li>
            <li class="listitem">
              <p>
                Estimated disk space required: 9.9 GB (2.4 GB installed with
                all listed languages; add 930 MB for tests)
              </p>
            </li>
            <li class="listitem">
              <p>
                Estimated build time: 25 SBU (with parallelism=4, add 62 SBU
                for tests with parallelism=4)
              </p>
            </li>
          </ul>
        </div>
        <h3>
          GCC Dependencies
        </h3>
        <h4>
          Recommended
        </h4>
        <p class="recommended">
          <a class="xref" href="dejagnu.html" title=
          "DejaGnu-1.6.2">DejaGnu-1.6.2</a>, for tests
        </p>
        <h4>
          Optional
        </h4>
        <p class="optional">
          <a class="xref" href="gdb.html" title="GDB-9.1">GDB-9.1</a>,
          <a class="xref" href="valgrind.html" title=
          "Valgrind-3.15.0">Valgrind-3.15.0</a> (for tests), and <a class=
          "ulink" href="https://repo.or.cz/isl.git">ISL</a> (to enable
          graphite optimization)
        </p>
        <p class="usernotes">
          User Notes: <a class="ulink" href=
          "http://wiki.linuxfromscratch.org/blfs/wiki/gcc">http://wiki.linuxfromscratch.org/blfs/wiki/gcc</a>
        </p>
      </div>
      <div class="installation" lang="en" xml:lang="en">
        <h2 class="sect2">
          Installation of GCC
        </h2>
        <div class="admon important">
          <img alt="[Important]" src="../images/important.png" />
          <h3>
            Important
          </h3>
          <p>
            Even if you specify only languages other than C and C++ to the
            <span class="command"><strong>./configure</strong></span> command
            below, the installation process will overwrite your existing
            <span class="application">GCC</span> C and C++ compilers and
            libraries. Having the <span class="application">Tcl</span>,
            <span class="application">Expect</span> and <span class=
            "application">DejaGnu</span> packages installed before beginning
            the build is highly recommended so you can run the full suite of
            tests.
          </p>
          <p>
            Do not continue with the <span class="command"><strong>make
            install</strong></span> command until you are confident the build
            was successful. You can compare your test results with those
            found at <a class="ulink" href=
            "http://gcc.gnu.org/ml/gcc-testresults/">http://gcc.gnu.org/ml/gcc-testresults/</a>.
            You may also want to refer to the information found in the
            <span class="application">GCC</span> section of Chapter 6 in the
            LFS book (<a class="ulink" href=
            "../../../../lfs/view/9.1/chapter06/gcc.html">../../../../lfs/view/9.1/chapter06/gcc.html</a>).
          </p>
        </div>
        <p>
          The instructions below are intentionally performing a <span class=
          "quote">&ldquo;<span class="quote">bootstrap</span>&rdquo;</span>
          process. Bootstrapping is needed for robustness and is highly
          recommended when upgrading the compilers version. To disable
          bootstrap anyways, add <em class=
          "parameter"><code>--disable-bootstrap</code></em> to the
          <span class="command"><strong>./configure</strong></span> options
          below.
        </p>
        <p>
          Install <span class="application">GCC</span> by running the
          following commands:
        </p>
        <pre class="userinput">
<kbd class="command">case $(uname -m) in
  x86_64)
    sed -e '/m64=/s/lib64/lib/' \
        -i.orig gcc/config/i386/t-linux64
  ;;
esac

sed -e '1161 s|^|//|' \
    -i libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.cc

mkdir build                                            &amp;&amp;
cd    build                                            &amp;&amp;

../configure                                           \
    --prefix=/usr                                      \
    --disable-multilib                                 \
    --with-system-zlib                                 \
    --enable-languages=c,c++,d,fortran,go,objc,obj-c++ &amp;&amp;
make</kbd>
</pre>
        <p>
          If you have installed additional packages such as <span class=
          "application">Valgrind</span> and <span class=
          "application">GDB</span>, the <span class="application">GCC</span>
          part of the testsuite will run more tests than in LFS. Some of
          those will report FAIL and others XPASS (pass when expected to
          FAIL). As of gcc-9.2.0, about 100 FAIL occur in the <span class=
          "quote">&ldquo;<span class="quote">guality</span>&rdquo;</span>
          suite, as well as miscellaneous failures throughout the rest of the
          test suite. If all the compilers above are built, there will be
          slightly over 120 unexpected failures out of over 390,000 tests. To
          run the tests, issue:
        </p>
        <pre class="userinput">
<kbd class="command">ulimit -s 32768 &amp;&amp;
make -k check</kbd>
</pre>
        <p>
          The tests are very long, and the results may be hard to find in the
          logs, specially if you use parallel jobs with make. You can get a
          summary of the tests with:
        </p>
        <pre class="userinput">
<kbd class="command">../contrib/test_summary</kbd>
</pre>
        <p>
          Now, as the <code class="systemitem">root</code> user:
        </p>
        <pre class="root">
<kbd class="command">make install &amp;&amp;

mkdir -pv /usr/share/gdb/auto-load/usr/lib              &amp;&amp;
mv -v /usr/lib/*gdb.py /usr/share/gdb/auto-load/usr/lib &amp;&amp;

chown -v -R root:root \
    /usr/lib/gcc/*linux-gnu/9.2.0/include{,-fixed}

rm -rf /usr/lib/gcc/$(gcc -dumpmachine)/9.2.0/include-fixed/bits/</kbd>
</pre>
        <p>
          Some packages expect to find the C preprocessor in <code class=
          "filename">/lib</code> or may refer to the C compiler under the
          name <span class="command"><strong>cc</strong></span>. The
          following symbolic links are not needed if you have followed the
          LFS instructions, since they have been already created. If you do
          not have them on your system, issue as the <code class=
          "systemitem">root</code> user:
        </p>
        <pre class="root">
<kbd class="command">ln -v -sf ../usr/bin/cpp /lib          &amp;&amp;
ln -v -sf gcc /usr/bin/cc              &amp;&amp;
install -v -dm755 /usr/lib/bfd-plugins &amp;&amp;
ln -sfv ../../libexec/gcc/$(gcc -dumpmachine)/9.2.0/liblto_plugin.so /usr/lib/bfd-plugins/</kbd>
</pre>
      </div>
      <div class="commands" lang="en" xml:lang="en">
        <h2 class="sect2">
          Command Explanations
        </h2>
        <p>
          <span class="command"><strong>mkdir build; cd
          build</strong></span>: The <span class="application">GCC</span>
          documentation recommends building the package in a dedicated build
          directory.
        </p>
        <p>
          <em class="parameter"><code>--disable-multilib</code></em>: This
          parameter ensures that files are created for the specific
          architecture of your computer.
        </p>
        <p>
          <em class="parameter"><code>--with-system-zlib</code></em>: Uses
          the system <span class="application">zlib</span> instead of the
          bundled one. <span class="application">zlib</span> is used for
          compressing and uncompressing <span class=
          "application">GCC</span>'s intermediate language in LTO (Link Time
          Optimization) object files.
        </p>
        <p>
          <em class=
          "parameter"><code>--enable-languages=c,c++,d,fortran,go,objc,obj-c++</code></em>:
          This command identifies which languages to build. You may modify
          this command to remove undesired languages. Two other languages can
          be added, besides ADA (see introduction above): BRIG (add
          <em class="parameter"><code>brig</code></em> to the list of enabled
          languages), a binary format for HSAIL (Heterogeneous System
          Architecture Intermediate Language), and JIT (add <em class=
          "parameter"><code>jit</code></em> to the list of enabled
          languages), a library which can be linked into interpreters that
          want to generate machine code <span class=
          "quote">&ldquo;<span class="quote">on the fly</span>&rdquo;</span>
          at run-time. They have not been tested by the BLFS developers.
        </p>
        <p>
          <span class="command"><strong>ulimit -s 32768</strong></span>: This
          command prevents several tests from running out of stack space.
        </p>
        <p>
          <span class="command"><strong>make -k check</strong></span>: This
          command runs the test suite without stopping if any errors are
          encountered.
        </p>
        <p>
          <span class=
          "command"><strong>../contrib/test_summary</strong></span>: This
          command will produce a summary of the test suite results. You can
          append <span class="command"><strong>| grep -A7
          Summ</strong></span> to the command to produce an even more
          condensed version of the summary. You may also wish to redirect the
          output to a file for review and comparison later on.
        </p>
        <p>
          <span class="command"><strong>mv -v /usr/lib/*gdb.py
          ...</strong></span>: The installation stage puts some files used by
          <span class="application">gdb</span> under the <code class=
          "filename">/usr/lib</code> directory. This generates spurious error
          messages when performing <span class=
          "command"><strong>ldconfig</strong></span>. This command moves the
          files to another location.
        </p>
        <p>
          <span class="command"><strong>chown -v -R root:root
          /usr/lib/gcc/*linux-gnu/...</strong></span>: If the package is
          built by a user other than root, the ownership of the installed
          <code class="filename">include</code> directory (and its content)
          will be incorrect. This command changes the ownership to the
          <code class="systemitem">root</code> user and group.
        </p>
        <p>
          <span class="command"><strong>rm -rf
          .../include-fixed/bits/</strong></span>: Remove an erroneous file
          in gcc added by the fixincludes process.
        </p>
      </div>
      <div class="content" lang="en" xml:lang="en">
        <h2 class="sect2">
          Contents
        </h2>
        <p>
          Some program and library names and descriptions are not listed
          here, but can be found at <a class="ulink" href=
          "../../../../lfs/view/9.1/chapter06/gcc.html#contents-gcc">../../../../lfs/view/9.1/chapter06/gcc.html#contents-gcc</a>
          as they were initially installed during the building of LFS.
        </p>
        <div class="segmentedlist">
          <div class="seglistitem">
            <div class="seg">
              <strong class="segtitle">Installed Programs:</strong>
              <span class="segbody">gccgo, go, gofmt, gdc and gfortran,
              hard-linked to architecture specific names</span>
            </div>
            <div class="seg">
              <strong class="segtitle">Installed Libraries:</strong>
              <span class="segbody">libgfortran.{so,a}, libgdruntime.{so,a},
              libgphobos.{so,a} libgo.{so,a}, libgobegin.a, libgolibbegin.a,
              libobjc.{so,a}, and numerous other run-time libraries and
              executables</span>
            </div>
            <div class="seg">
              <strong class="segtitle">Installed Directories:</strong>
              <span class="segbody">/usr/lib/go</span>
            </div>
          </div>
        </div>
        <div class="variablelist">
          <h3>
            Short Descriptions
          </h3>
          <table border="0" class="variablelist">
            <colgroup>
              <col align="left" valign="top" />
              <col />
            </colgroup>
            <tbody>
              <tr>
                <td>
                  <p>
                    <a id="gccgo" name="gccgo"></a><span class=
                    "term"><span class=
                    "command"><strong>gccgo</strong></span></span>
                  </p>
                </td>
                <td>
                  <p>
                    is a GCC-based compiler for the <span class=
                    "application">Go</span> language.
                  </p>
                </td>
              </tr>
              <tr>
                <td>
                  <p>
                    <a id="go" name="go"></a><span class="term"><span class=
                    "command"><strong>go</strong></span></span>
                  </p>
                </td>
                <td>
                  <p>
                    is a tool for managing <span class=
                    "application">Go</span> source code.
                  </p>
                </td>
              </tr>
              <tr>
                <td>
                  <p>
                    <a id="gofmt" name="gofmt"></a><span class=
                    "term"><span class=
                    "command"><strong>gofmt</strong></span></span>
                  </p>
                </td>
                <td>
                  <p>
                    is a tool for formatting <span class=
                    "application">Go</span> source code.
                  </p>
                </td>
              </tr>
              <tr>
                <td>
                  <p>
                    <a id="gdc" name="gdc"></a><span class=
                    "term"><span class="command"><strong>gdc</strong></span></span>
                  </p>
                </td>
                <td>
                  <p>
                    is a GCC-based compiler for the <span class=
                    "application">D</span> language.
                  </p>
                </td>
              </tr>
              <tr>
                <td>
                  <p>
                    <a id="gfortran" name="gfortran"></a><span class=
                    "term"><span class=
                    "command"><strong>gfortran</strong></span></span>
                  </p>
                </td>
                <td>
                  <p>
                    is a GCC-based compiler for the <span class=
                    "application">Fortran</span> language.
                  </p>
                </td>
              </tr>
            </tbody>
          </table>
        </div>
      </div>
      <p class="updated">
        Last updated on 2020-02-18 12:45:12 -0800
      </p>
    </div>
    <div class="navfooter">
      <ul>
        <li class="prev">
          <a accesskey="p" href="expect.html" title="Expect-5.45.4">Prev</a>
          <p>
            Expect-5.45.4
          </p>
        </li>
        <li class="next">
          <a accesskey="n" href="gc.html" title="GC-8.0.4">Next</a>
          <p>
            GC-8.0.4
          </p>
        </li>
        <li class="up">
          <a accesskey="u" href="prog.html" title=
          "Chapter&nbsp;13.&nbsp;Programming">Up</a>
        </li>
        <li class="home">
          <a accesskey="h" href="../index.html" title=
          "Beyond Linux� From Scratch     (System V Edition) - Version 9.1">Home</a>
        </li>
      </ul>
    </div>
  </body>
</html>
